home *** CD-ROM | disk | FTP | other *** search
/ Your Choice 3 / Your Choice Software Collection 3.iso / prgmming / swag08 / cursor.swg < prev    next >
Text File  |  1994-09-22  |  6KB  |  1 lines

  1. SWAGOLX.EXE (c) 1993 GDSOFT  ALL RIGHTS RESERVED 00002                                                                           1      08-24-9413:29ALL                      GRANT BEATTIE            Cursor Unit              SWAG9408    5,M    13     .]   Unit Cursor;  { Cursor.Pas }ππinterfaceππconstπCursorOn  = True;πCursorOff = False;ππ{ Cursor shapes }ππThinCursor    = $0707; { Thin cursor }πOvrCursor     = $0307; { Overwrite cursor }πInsCursor     = $0607; { Insert cursor (default) }πBarCursor     = $000D; { Bar cursor }ππprocedure SetCursor(CursorFlag : boolean);πfunction GetCursorType : word;πfunction SetCursorType(Shape : word) : word;ππimplementationππuses Crt;ππvarπCursorShape : word;ππProcedure SetCursor; assembler;ππ{ Sets the cursor on/off using the current value of the globalπCursorShape variable. Monochrome monitors supported }πAsmπCMP CursorFlag,TrueπJNE @@2πCMP BYTE PTR [LastMode],MonoπJE  @@1πMOV CX,CursorShape  { Switch on cursor using the default shape }πJMP @@4π@@1:πMOV CX,0B0Ch  { Switch on mono cursor }πJMP @@4π@@2:πCMP BYTE PTR [LastMode],MonoπJE  @@3πMOV CX,2000h  { Switch off cursor }πJMP @@4π@@3:πXOR CX,CX     { Switch off mono cursor }π@@4:πMOV AH,01hπXOR BH,BHπINT 10hπEnd; { SetCursor }ππFunction GetCursorType;ππ{ Returns the current cursor shape/type in word }ππBeginπGetCursorType := MemW[Seg0040:$0060]πEnd; { GetCursorType }ππFunction SetCursorType; assembler;ππ{ Sets new cursor type/shape. Old cursor shape is returned }ππAsmπMOV AX,CursorShape { save old value }πMOV BX,ShapeπCMP BYTE PTR [LastMode],MonoπJNE @@1πXOR BX,BX { Switch off mono cursor }π@@1:πMOV CursorShape,BXπEnd; { SetCursorType }ππBeginπCursorShape := GetCursorTypeπEnd. { Cursor.Pas }π                                                                                   2      08-24-9413:29ALL                      BAS VAN GAALEN           cursor stuff             SWAG9408    YuΘM    34     .]   {To make all cursor routines complete, here are the ones I use: }ππprocedure setcursorshape(shape : word); assembler; asmπ  mov ah,1; mov cx,shape; int 10h; end;ππprocedure linecursor;πbeginπ  case Rows ofπ    25 : case VidCard ofπ           cga,ega : setcursorshape(256*6+7);π           mda : setcursorshape(256*$b+$c);π           vga : setcursorshape(256*$d+$e);π         else setcursorshape(256*6+7);π         end;π    40 : setcursorshape(256*8+9);π  else setcursorshape(256*6+7);π  end;πend;ππprocedure halfcursor;πbeginπ  case Rows ofπ    25 : case VidCard ofπ           cga,ega : setcursorshape(256*3+7);π           mda : setcursorshape(256*6+$c);π           vga : setcursorshape(256*7+$e);π         else setcursorshape(256*3+7);π         end;π    40 : setcursorshape(256*4+9);π  else setcursorshape(256*3+7);π  end;πend;ππprocedure blockcursor; beginπ  setcursorshape($10); end;ππprocedure cursoron; assembler; asmπ  mov ah,3; mov bh,0; int 10h; and ch,not 20h; mov ah,1; int 10h; end;ππprocedure cursoroff; assembler; asmπ  mov ah,3; mov bh,0; int 10h; or ch,20h; mov ah,1; int 10h; end;ππfunction getcursorshape : word; assembler; asmπ  mov ah,3; mov bh,0; int 10h; mov ax,cx; end;ππ>--- cut here ππThe carddetectionroutines are as follows:ππ>--- cut here ππconstπ  mda = 0;                                                     { MDA and HGC }π  cga = 1;π  ega = 2;π  ega_mono = 3;                                        { EGA and MDA-Monitor }π  vga = 4;π  vga_mono = 5;                                           { VGA and VGA-Mono }π  mcga = 6;π  mcga_mono = 7;                                        { MCGA and MCGA-Mono }ππvarπ  VidCard : byte;                                { Code for active videocard }ππprocedure VideoInit;ππconstπ  VidMode : array[0..11] of byte = (mda,cga,0,ega,ega_mono,0,vga_mono,π                                    vga,0,mcga,mcga_mono,mcga);π  EgaMode : array[0..2] of byte = (ega,ega,ega_mono);ππvarπ  Regs : registers;                           { Processorregisters for int's }ππbeginπ  VidCard := $ff;                                { No videocard detected yet }ππ  { --- Check card-type ---------------------------------------------------- }ππ  Regs.ax := $1a00;                                 { Call BIOS function 1Ah }π  intr($10,Regs);π  if Regs.al = $1a then begin                           { VGA of MCGA? - Yes }π    VidCard := VidMode[Regs.bl-1];                      { Get cod from table }π    Color := not ((VidCard = mda) or (VidCard = ega_mono));π  endπ  else begin                               { No VGA or MCGA, search EGA-card }π    Regs.ah := $12;                           { Function 12h subfunction 10h }π    Regs.bl := $10;π    intr($10,Regs);                                        { Call Video-BIOS }π    if Regs.bl <> $10 then begin                                { EGA? - Yes }π      VidCard := EgaMode[(Regs.cl shr 1) div 3];                  { Get Code }π      Color := VidCard <> ega_mono;π    end;π  end;ππ  { --- Define pointer to video-RAM ---------------------------------------- }ππ  Regs.ah := 15;                                  { Define actual video-mode }π  intr($10,Regs);                                { Call BIOS video-interrupt }π  if Regs.al = 7 then v_vidseg := $b000                   { Monochrome mode? }π  else v_vidseg := $b800;                                    { No, Colormode }ππ  if VidCard = $ff then begin                   { No EGA, VGA or MCGA? - Yes }π    if Regs.al = 7 then VidCard := mda else VidCard := cga;π    Color := not ((Regs.al = 0) or (Regs.al = 2) or (Regs.al = 7));π    SnowProtect := true;π  end;ππ  Regs.ah := 5;                                   { Chose actual screen page }π  Regs.al := 0;                                                  { Page zero }π  intr($10,Regs);                                { Call BIOS video-interrupt }πend;ππ>--- cut here ππThis might not compile straight off, but I guess you can imagine what'sπpossibly missing. ;-) (like 'uses dos')ππIf everything works, you can easily define your cursor with statements as:ππlinecursor,πblockcursor,πcursoroff,πcursoron,πetc...ππShould work on every possible videocard.π